package com.lurencun.android.topicbank.presist;

import com.j256.ormlite.dao.ForeignCollection;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.field.ForeignCollectionField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable(tableName = "exam_paper")
public class Paper {
	
	
	@DatabaseField(generatedId = true)
	private Long id;
	
	/** 试卷ID **/
	@DatabaseField
	private Long paperId;
	
	/** 试卷类型 **/
	@DatabaseField
	private int type;
	
	/** 类型标题 **/
	@DatabaseField
	private String typeTitle;
	
	/** 试卷名称 **/
	@DatabaseField
	private String title;
	
	/** 试卷描述 **/
	@DatabaseField
	private String describe;
	
	/** 创建者 **/
	@DatabaseField
	private String creator;
	
	/** 试题数 **/
	@DatabaseField
	private int topicCount;
	
	/** 价格 **/
	@DatabaseField
	private float price;
	
	/** 是否已经购买 **/
	@DatabaseField
	private boolean purchased;

	@ForeignCollectionField(eager = true)    //必须是ForeignCollection<>
	private ForeignCollection<Topic> topics;
	
	public Paper() {
		
	}
	
	public Paper(String title) {
		this.title = title;
	}


	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescribe() {
		return describe;
	}

	public void setDescribe(String describe) {
		this.describe = describe;
	}

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public int getTopicCount() {
		return topicCount;
	}

	public void setTopicCount(int topicCount) {
		this.topicCount = topicCount;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	public boolean isPurchased() {
		return purchased;
	}

	public void setPurchased(boolean purchased) {
		this.purchased = purchased;
	}
	
	public ForeignCollection<Topic> getTopics() {
		return topics;
	}

	public void setTopics(ForeignCollection<Topic> topics) {
		this.topics = topics;
	}

	public Long getPaperId() {
		return paperId;
	}

	public void setPaperId(Long paperId) {
		this.paperId = paperId;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	
	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getTypeTitle() {
		return typeTitle;
	}

	public void setTypeTitle(String typeTitle) {
		this.typeTitle = typeTitle;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("id=").append(id);
		sb.append("paperId=").append(paperId);
		sb.append(" ,title=").append(title);
		sb.append(" ,purchased=").append(purchased);
		if(getTopics()!=null) {
			sb.append(" ,size=").append(getTopics().size());
		}
		return sb.toString();
	}
}
